package com.ruibang.glass.portal.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.portal.domain.AreaPageReq;
import com.ruibang.glass.portal.domain.AreaReq;
import com.ruibang.glass.portal.entity.Area;
import com.ruibang.glass.portal.mapper.AreaMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-15  09:17
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Service
public class AreaService extends ServiceImpl<AreaMapper, Area> implements IService<Area> {


    /**
     * 获取区域列表
     *
     * @param areaPageReq
     * @return
     */
    public IPage<Area> queryAreas(AreaPageReq areaPageReq) {
        return baseMapper.queryAreas(new Page<>(areaPageReq.getPageNo(), areaPageReq.getPageSize()), areaPageReq);
    }

    /**
     * 修改区域
     *
     * @param area
     */
    public void updateArea(Area area) {
        this.updateById(area);
    }

    /**
     * @Description: 根据产线获取区域
     * @version v1.0
     * @author songJinKang
     * @date 2023-11-22 15:36
     */
    public List<Area> getByProductLineId(String id) {
        return lambdaQuery().eq(Area::getProductLineId, id).list();
    }


    /**
     * @Description: 条件获取区域列表
     * @version v1.0
     * @author songJinKang
     * @date 2023-11-28 15:11
     */
    public List<Area> getAreaList(AreaReq areaReq) {
        return baseMapper.getAreaList(areaReq);
    }

}
